﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZOVNP.Model.Abstracts;

namespace ZOVNP.Engine
{
    [DomainObject(typeof(IProductType))]
    public partial class ProductType : IProductType
    {
        private IDomainCollection<IProduct> _productsLocker;
        private IDomainCollection<IProductType> _childTypesLocker;
        private IDomainReference<IProductType> _parentTypeLocker;

        public ProductType()
        {
            _productsLocker = new SmartCollection<Product, IProduct>(this, Products);
            _parentTypeLocker = new SmartReference<ProductType, ProductType, IProductType>(this, ParentProductTypeReference, it => it._ParentProductTypeID);
            _childTypesLocker = new SmartCollection<ProductType, IProductType>(this, ProductTypes);
        }

        IDomainCollection<IProduct> IProductType.Products
        {
            get { return _productsLocker; }
        }

        IDomainCollection<IProductType> IProductType.ProductTypes
        {
            get { return _childTypesLocker; }
        }

        IDomainReference<IProductType> IProductType.ParentProductType
        {
            get { return _parentTypeLocker; }
        }
    }
}
